home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Primer Plus
/
Java Primer Plus (Waite Group Proess)(1996).iso
/
chapter10
/
wordpro.java
< prev
Wrap
Text File
|
1995-12-31
|
1KB
|
59 lines
/* Abstract class for word processor files */
abstract class word_processor_file {
/* Non-abstract method for reading binary files */
public byte[] read_from_disk(String filename) {
System.out.println("read from disk...");
// code to read in disk file and return byte[]
return new byte[10];
}
/* Abstract method for displaying format onto the screen */
abstract public void display_file();
}
interface byteable {
public byte[] decode_to_bytes();
}
class WordPerfect_file extends word_processor_file
implements byteable {
byte myFile[];
/* Constructor */
public WordPerfect_file(String filename) {
myFile = read_from_disk(filename);
}
/* Overriding the abstract method */
public void display_file() {
// intricate format and screen-displaying details
}
/* Satisfy the interface */
public byte[] decode_to_bytes() {
// code to decode myFile into a plain stream
// of text (bytes)
return new byte[40]; // test test test
}
}
class testword {
public static void main (String args[]) {
WordPerfect_file W = new WordPerfect_file("aaa");
W.display_file();
}
}